import org.junit.Assert;
import org.junit.Test;

public class NGuessNumberTest {
    @Test
    public void generateAnswerTest(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        Integer[] integers = nGuessNumber.generateAnswer();
        // //断言检查答案数字数量是否为4
        Assert.assertEquals(integers.length,4);
        //断言判断是否有重复数字
        for (int i = 0; i < integers.length; i++) {
            for (int j = i+1; j < integers.length; j++) {
                Assert.assertNotEquals(integers[i],integers[j]);
            }
        }
        //判断数字是否都在0-9之间
        for (Integer integer : integers) {
            if(integer>=0&&integer<=9){
                System.out.println("检测通过");
            }else {
                System.out.println("检测失败");
            }
        }
    }
    @Test
    public void getPlayerInputTest(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        Integer[] playerInput = nGuessNumber.getPlayerInput();
        Assert.assertEquals(playerInput.length,4);
    }
    @Test
    public void compareGuessAnswerTest(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        String s = nGuessNumber.compareGuessAnswer(nGuessNumber.generateAnswer(),nGuessNumber.getPlayerInput());
        Assert.assertEquals(s.length(),4);
    }
    @Test
    public void isWinTest(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        boolean win = nGuessNumber.isWin(nGuessNumber.generateAnswer(),nGuessNumber.getPlayerInput());
        System.out.println(win);
    }
}
